(function(plugIn) {

  jsx3.$O(plugIn).extend({

    paint: function(objContainer) {
      var Wizard = com.tibco.amx.Wizard;
      //alert(Wizard)
      var WizardPane = com.tibco.amx.WizardPane;

      var layout = this.loadRsrcComponent("layout", objContainer, false);

      var wizard = new Wizard();
      wizard.setRandomAccess(true);

      jsx3.$A(["pane1", "pane2", "pane3", "pane4"]).each(jsx3.$F(function(e) {
        var rsrc = this.getResource(e);
        var images = rsrc.attr("images");
        images = images ? images.split(/\s+/g) : [];
        var pane = new WizardPane(rsrc, this, {title:rsrc.attr("title"), images:images});
        wizard.addPane(pane);
      }).bind(this));

      wizard.renderIn(layout.getWizardContainer());

      wizard.subscribe(Wizard.CANCEL, this, function() {
        layout.getDialog().doClose();
        this.getServer().alert(null, "Canceled!");
      });

      wizard.subscribe(Wizard.FINISH, this, function() {
        layout.getDialog().doClose();
        var session = wizard.getSession();
        var s = "";
        for (var f in session)
          s += f + "=" + session[f] + " ";
        this.getServer().alert(null, "Finished!<br/><br/>" + s);
      });

      objContainer.paintChild(layout);
    }
    
  });

})(this);
